import { Module, NestModule, MiddlewareConsumer } from '@nestjs/common';
import { ApiGatewayController } from './api-gateway.controller';
import { ApiGatewayService } from './api-gateway.service';
// @app/common
import {
  AcmeChallengeMiddleware,
  CommonModule as AppCommonModule,
} from '@app/common';
import {
  AuthModule,
  CertificateModule,
  CloudModule,
  CoinModule,
  CommonModule,
  DnsModule,
  MessageModule,
  NotificationModule,
  UserModule,
  WatchModule,
} from '.';

@Module({
  imports: [
    // common
    AppCommonModule,
    // modules
    CertificateModule,
    AuthModule,
    CloudModule,
    CoinModule,
    CommonModule,
    DnsModule,
    MessageModule,
    NotificationModule,
    UserModule,
    WatchModule,
  ],
  controllers: [ApiGatewayController],
  providers: [ApiGatewayService],
})
export class ApiGatewayModule implements NestModule {
  configure(consumer: MiddlewareConsumer) {
    consumer.apply(AcmeChallengeMiddleware).forRoutes('*');
  }
}
